import { HurdlesGameConfig } from "./HurdlesGameConfig";

export class HurdlesData {
  public levelIndex: number = 0;
  constructor(li: number) {
    this.levelIndex = li;
  }
  public isFinishedAllBarrier() {
    return this.levelIndex >= HurdlesGameConfig.hurdlesLevelInfo.length;
  }
  public initLevel(lv: number) {
    this.levelIndex = lv;
  }
  public getHurdlesConfig() {
    return HurdlesGameConfig.getHurdlesInfo(this.levelIndex);
  }

  public addLevel() {
    this.levelIndex += 1;
    if (this.levelIndex >= HurdlesGameConfig.hurdlesLevelInfo.length) {
      this.levelIndex = HurdlesGameConfig.hurdlesLevelInfo.length;
    }
  }

  public maxHitNum() {
    const c = HurdlesGameConfig.getHurdlesInfo(this.levelIndex);
    return c.maxHitNum;
  }
}